import request from "@/config/request/index";
import {AccessToken} from "@/types/auth";

enum API {
    root = '/member/auth'
}

/**
 * 微信手机号快捷登录
 */
export function weiXinMiniAppPhoneLogin(
    phoneCode: string, loginCode: string, state: string) {
    return request.post<BaseResult<AccessToken>>({
        url: `${API.root}/weixin-mini-app-login`,
        data: {phoneCode, loginCode, state},
    });
}

/**
 * 微信快捷授权
 */
export function weiXinMiniAppLogin(
    code: string, state: string, type: number) {
    return request.post<BaseResult<AccessToken>>({
        url: `${API.root}/social-login`,
        data: {code, state, type}
    })
}


/**
 * 刷新 Token
 */
export function refreshToken(refreshToken: string) {
    return request.post<BaseResult<AccessToken>>({
        url: `${API.root}/refresh-token`,
        params: {refreshToken},
        custom: {showLoader: false}
    });
}

